package com.modules.main;

import com.base.mvvm.BasePresenterImpl;
import com.face.gaoml.netlibrary.data.rusult.BaseSubscriber;
import com.face.gaoml.netlibrary.data.rusult.HttpResultFunc;
import com.gml.gao.databinding.MainActivityBinding;
import com.modules.bean.User;

import javax.inject.Inject;

/**
 * MVPPlugin
 *  邮箱 784787081@qq.com
 */

public class MainModle extends BasePresenterImpl<MainActivityBinding> {

    @Inject  //1 构造函数 提供支援 提供对象     2.注入构造器所需要的参数的依赖 （ 注入传递）
    public MainModle() {
    }

    /**
     * 登录 请求
     *
     * @param name
     * @param pass
     */
    public void login(String name, String pass) {
        mRxManager.addSubscription(
                apiStores.login("86", name, pass)
                        .map(new HttpResultFunc<User>()),
                new BaseSubscriber<User>() {
                    @Override
                    public void onNext(User result) {
                        if (result != null) {
//                            mvpView.loginSucc(result);
                            mvpView.setViewModel(result);
//                            mvpView.Succ(result);
                        }
                    }
                }

        );
    }
}
